<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>
<html>
<head>
	<link rel="stylesheet" href="<c:url value="/resources/css/bootstrap.css" />" >
	<link rel="stylesheet" href="<c:url value="/resources/css/bootstrap-theme.css" />" >
	<script type="text/javascript" src="<c:url value="/resources/js/jquery-2.1.1.js" /> "></script>
	<script type="text/javascript" src="<c:url value="/resources/js/bootstrap.js" /> "></script>
	<title>Register Page</title>
	<style type="text/css">
		.errors {
			color: #ff0000;
			font-size: italic;
			font-weight: bold;
		}
	</style>
</head>
<body>
	<div class="container">
      <!-- Static navbar -->
      <div class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="<spring:url value="/" />">Spring MVC</a>
          </div>
          <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
              <li><a href="<spring:url value="/" />">Home</a></li>
              <security:authorize access="! isAuthenticated()">
              <li><a href="<spring:url value="/login" />">Login</a></li>
              </security:authorize>
              <security:authorize access="isAuthenticated()">
              <li><a href="<spring:url value="/listuser" />">List Users</a></li>
              </security:authorize>
              <li  class="active"><a href="<spring:url value="/register" />">Register</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
              <security:authorize access=" isAuthenticated()" >
              <li><a>Welcome ${pageContext.request.userPrincipal.name}</a></li>
              </security:authorize>
              <security:authorize access=" isAuthenticated()">
               <li><a href="<spring:url value="/logout" />">Logout</a></li>
              </security:authorize>
            </ul>
          </div><!--/.nav-collapse -->
        </div><!--/.container-fluid -->
      </div>
    </div> <!-- /container -->
    
    <div class="container">
    <form:form action="${pageContext.request.contextPath}/register/registerform" modelAttribute="user" cssClass="form-horizontal" role="form" method="post">
      <div class="form-group">
	    <label for="username" class="col-sm-2 control-label">Username</label>
	    <div class="col-sm-6">
	      <form:input cssClass="form-control" path="username" placeholder="Username" />
	      <form:errors cssClass="errors" path="username" />
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="password" class="col-sm-2 control-label">Password</label>
	    <div class="col-sm-6">
	      <form:password cssClass="form-control" path="password" placeholder="Password" />
	      <form:errors cssClass="errors" path="password" />
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="idcard" class="col-sm-2 control-label">ID Card Number</label>
	    <div class="col-sm-6">
	      <form:input class="form-control" path="idcard" placeholder="ID Card Number" />
	      <form:errors cssClass="errors" path="idcard" />
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="firstname" class="col-sm-2 control-label">First Name</label>
	    <div class="col-sm-6">
	      <form:input class="form-control" path="firstname" placeholder="First Name" />
	      <form:errors cssClass="errors" path="firstname" />
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="lastname" class="col-sm-2 control-label">Last Name</label>
	    <div class="col-sm-6">
	      <form:input class="form-control" path="lastname" placeholder="Last Name" />
	      <form:errors cssClass="errors" path="lastname" />
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="phone" class="col-sm-2 control-label">Phone</label>
	    <div class="col-sm-6">
	      <form:input class="form-control" path="phone" placeholder="Phone" />
	      <form:errors cssClass="errors" path="phone" />
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="email" class="col-sm-2 control-label">Email</label>
	    <div class="col-sm-6">
	      <form:input class="form-control" path="email" placeholder="Email" />
	      <form:errors cssClass="errors" path="email" />
	    </div>
	  </div>
	  <div class="form-group">
	    <div class="col-sm-offset-2 col-sm-10">
	      <input type="submit" class="btn btn-default btn-primary" value="Register"></button>
	    </div>
	  </div>
	</form:form>
    </div>
    
    <div class="container">
    	<div class="navbar navbar-default navbar-fixed-bottom">
    		<div class="container">
    			<p class="navbar-text">&copy; Hai Nguyen|Java Fresher</p>
    			<a href="#" class="navbar-btn btn btn-danger pull-right"><span class="glyphicon glyphicon-chevron-up"></span>Back To Top</a>
    		</div>
    	</div>
    </div>
    
</body>
</html>
